{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{:lang('user')}{:lang('list')}</legend>
    </fieldset>
    <div class="demoTable">
        <div class="layui-inline">
            <input class="layui-input" name="key" id="key" placeholder="{:lang('pleaseEnter')}关键字">
        </div>
        <button class="layui-btn" id="search" data-type="reload">搜索</button>
        <a href="{:url('index')}" class="layui-btn">显示全部</a>
        <a href="{:url('user_daochu')}" class="layui-btn">导出</a>
     
    </div>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
<script type="text/html" id="is_lock">
    <input type="checkbox" name="is_lock" value="{{d.id}}" lay-skin="switch" lay-text="已激活|未激活" lay-filter="is_lock" {{ d.activation == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="lock">
    <input type="checkbox" name="lock" value="{{d.id}}" lay-skin="switch" lay-text="已锁定|未锁定" lay-filter="lock" {{ d.is_lock == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="action">
    <a href="{:url('edit')}?id={{d.id}}" class="layui-btn layui-btn-xs">编辑</a>
    <a href="{:url('/admin/autologin/index')}?userid={{d.id}}"  class="layui-btn layui-btn-xs" target="_blank">登录</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/html" id="login">
    <a href="{:url('/admin/autologin/index')}?userid={{d.id}}"  class="layui-btn layui-btn-xs" target="_blank">{{d.nickname}}</a>
    <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
</script>
<script type="text/html" id="email">
    {{d.email}}
    {{# if(d.email && d.email_validated=='0'){ }}
    (未验证)
    {{# } }}
</script>
{include file="common/foot"/}
<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form, $ = layui.jquery;
        var tableIn = table.render({
            id: 'user',
            elem: '#list',
            url: '{:url("index")}',
            method: 'post',
            page: true,
            cols: [[
              //  {checkbox:true,fixed: true},
                {field: 'id', title: '{:lang("id")}', width: 80, fixed: true},
                {field: 'nickname', title: '会员编号', width: 90,toolbar: '#login'},
                {field: 'username', title: '会员姓名', width: 90},
                {field: 'level_name', title: '会员等级', width: 100},
/*                {field: 'tlevel_name', title: '代理等级', width: 100},*/
             //   {field: 'email', title: '{:lang("email")}', width: 250,templet:'#email'},
                {field: 'mobile', title: '{:lang("tel")}', width: 120},
				{field: 'up_userid', title: '{:lang("推荐人")}', width: 120},
				{field: 'fatherid', title: '{:lang("安置人")}', width: 120},
/*				{field: 'center_id', title: '{:lang("服务中心")}', width: 120},*/
				{field: 'money_jifen', title: '{$money_jifen}', width: 100},
/*				{field: 'money_qian', title: '{$money_qian}', width: 100},
				{field: 'money_benjin', title: '{$money_benjin}', width: 100},
				{field: 'money_qita', title: '{$money_qita}', width: 100},
				{field: 'money_baodan', title: '{$money_baodan}', width: 100},*/
				{field: 'recount', title: '{:lang("推荐人数")}', width: 100},
                {field: 'activation', align: 'center',title: '{:lang("status")}', width: 120,toolbar: '#is_lock'},
                {field: 'is_lock', align: 'center',title: '锁定状态', width: 120,toolbar: '#lock'},
                {field: 'reg_time', title: '注册时间', width: 150},
                {field: 'jihuo_time', title: '激活时间', width: 150},
                {width: 160, align: 'center', toolbar: '#action'}
            ]],
            limit: 10 //每页默认显示的数量
        });
 /*       form.on('switch(is_lock)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = this.value;
            var is_lock = obj.elem.checked===true?1:0;
            $.post('{:url("usersState")}',{'id':id,'is_lock':is_lock},function (res) {
                layer.close(loading);
                if (res.status==1) {
                    tableIn.reload();
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                    tableIn.reload();
                    return false;
                }
            })
        });*/
        form.on('switch(lock)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = this.value;
            var lock = obj.elem.checked===true?1:0;
            $.post('{:url("user_lock")}',{'id':id,'lock':lock},function (res) {
                layer.close(loading);
                if (res.status==1) {
                    tableIn.reload();
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                    tableIn.reload();
                    return false;
                }
            })
        });
        //搜索
        $('#search').on('click', function() {
            var key = $('#key').val();
            if($.trim(key)==='') {
                layer.msg('{:lang("pleaseEnter")}关键字！',{icon:0});
                return;
            }
            tableIn.reload({ page: {page: 1},where: {key: key}});
        });
        table.on('tool(list)', function(obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('您确定要删除该会员吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("{:url('usersDel')}",{id:data.id},function(res){
                        layer.close(loading);
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg('操作失败！',{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });

      //去掉删除全部
    });
</script>
</body>
</html>